<template>
	<view class="msgitem" @click="to('/pages/msg/detail?id='+item.id)">
		<view class="msgitem__top">
			<view class="u-flex u-flex-y-center">
				<u-avatar :src="URL(item.avatar)" shape="circle" size="57rpx" mode="aspectFill"></u-avatar>
				<view class="msgitem__nickname">
					{{item.contract}}
				</view>
				<view class="msgitem__zd" v-if="item.type==2">
					置顶
				</view>
			</view>
			<view class="u-flex u-flex-y-center">
				<view class="msgitem__tag" v-if="item.category_name">
					{{item.category_name}}
				</view>
				<view class="msgitem__tag" v-if="item.is_other==2">
					其他信息
				</view>
				<view @click.stop="callphone(item.phone)">
					<u-icon name="/static/msg/mobile.png" size="62rpx"></u-icon>
				</view>
			</view>
		</view>
		<view class="msgitem__content">
			{{item.text}}
		</view>
		<view class="msgitem__piclist" v-if="item.imags.length>0">
			<u-album :urls="item.imags"></u-album>
		</view>
		<view class="u-flex u-flex-y-center u-flex-between">
			<view class="msgitem__time">
				{{$u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM')}}
			</view>
			<view class="u-flex u-flex-y-center">
				<view class="u-flex u-flex-y-center">
					<u-icon name="eye" color="#1A1A1A" size="44rpx"></u-icon>
					<view class="msgitem__num">
						{{item.view}}
					</view>
				</view>
				<view class="u-flex u-flex-y-center">
					<u-icon name="share-square" color="#1A1A1A" size="44rpx"></u-icon>
					<view class="msgitem__num">
						{{item.share}}
					</view>
				</view>
				<view class="u-flex u-flex-y-center" @click.stop="dianz">
					
					<view class="">
						<u-icon name="star" v-if="!isCollect" color="#1A1A1A" size="44rpx"></u-icon>
						<u-icon name="star-fill" v-else color="#E8BF05" size="44rpx"></u-icon>
					</view>
					<view class="msgitem__num">
						{{collect}}
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import home from '@/api/_home.js'
	export default {
		name: "msgitem",
		props:{
			item:{}
		},
		data() {
			return {
				urls2: [],
				isCollect:null,
				collect:0
			};
		},
		methods:{
			dianz(){
				this.isCollect=!this.isCollect
				home.infoCollect({id:this.item.id}).then(res=>{
					uni.$u.toast('操作成功')
				})
				if(this.isCollect){
					this.collect++
				}
				if(!this.isCollect){
					this.collect--
				}
				this.$emit('dianz',this.isCollect)
				this.$forceUpdate()
			}
		},
		created() {
			this.isCollect=this.item.isCollect
			this.collect=this.item.collect
			
		},
	}
</script>

<style lang="scss">
	.msgitem {
		padding: 38rpx 20rpx 30rpx 30rpx;
		border-bottom: 2rpx solid #F4F6F8;
		background-color: #fff;
		&__top {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-right: 10rpx;
		}

		&__nickname {
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 26rpx;
			color: #5A5A5A;
			line-height: 26rpx;
			margin: 0 8rpx;
		}

		&__zd {
			padding: 0 9rpx;
			height: 36rpx;
			background: #E1BC13;
			border-radius: 18rpx 18rpx 18rpx 0rpx;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 22rpx;
			color: #7A3807;
			line-height: 36rpx;
		}

		&__tag {
			padding: 0 10rpx;
			height: 47rpx;
			background: #F7F7F9;
			border-radius: 8rpx;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 25rpx;
			color: #4E4D52;
			line-height: 47rpx;
			margin-right: 15rpx;
		}

		&__content {
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 30rpx;
			color: #2C2A2A;
			line-height: 40rpx;
			padding: 14rpx 0 20rpx;
		}
		&__piclist {
			margin-bottom: 40rpx;
		}
		&__time{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 24rpx;
			color: #5A5A5A;
			line-height: 24rpx;
		}
		&__num{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 24rpx;
			color: #3C3C3C;
			line-height: 24rpx;
			margin: 0 50rpx 0 12rpx ;
		}
	}

	/deep/.u-album__row__wrapper {
		uni-image{
			width: 222rpx!important;
			height: 222rpx!important;
		}
		/deep/image{
			width: 222rpx!important;
			height: 222rpx!important;
		}
	}
	
</style>